/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package convert;

import bean.CompanyBean;
import ejb.Company;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

/**
 *
 * @author longdm
 */
public class companyConverter implements Converter {

    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        CompanyBean cb = new CompanyBean();
        cb.setCompanyId(Integer.parseInt(value));
        return cb.getCompanyById();
    }

    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return ((Company)value).getCompanyId().toString();
    }

}
